package model.factories.turtlequeries;

import java.util.Map;
import java.util.Scanner;
import java.util.regex.Pattern;
import model.Interpreter;
import model.SyntaxErrorException;
import model.commands.Command;
import model.commands.turtlequeries.HeadingCommand;
import model.factories.CommandFactory;


/**
 * A factory that creates HeadingCommand objects.
 * 
 * @author Erick Gonzalez
 */
public class HeadingCommandFactory extends CommandFactory {
    /**
     * A pattern that matches HEADING command keywords.
     */
    private final Pattern myHeadingPattern = Pattern.
            compile(getInterpreter().getLanguage().getString("HeadingCommandPattern"));

    /**
     * 
     * @param interpreter an interpreter
     */
    public HeadingCommandFactory (Interpreter interpreter) {
        super(interpreter);
    }

    @Override
    public Command createCommand (Scanner commandReader,
                                  Map<String, Integer> variables) throws SyntaxErrorException {
        // read the command keyword
        commandReader.next();
        return new HeadingCommand();
    }

    @Override
    public Pattern patternToMatch () {
        return myHeadingPattern;
    }

}
